package com.wzl.day14;


/**
 * 找出最长的子字符串，leecode第3题
 */
public class day14 {
    public int lengthOfLongestSubstring(String s) {
        if (s == null || s.length() == 0) {
            return 0;
        }
        boolean[] chars = new boolean[256];
        int rst = 0;
        int start = 0;
        int end = 0;
        while (start < s.length()) {
            while (end < s.length() && !chars[s.charAt(end)]) {
                chars[s.charAt(end)] = true;
                rst = Math.max(rst, end - start + 1);
                end++;
            }
            chars[s.charAt(start)] = false;
            start++;
        }
        return rst;

    }

    public static void main(String[] args) {
        String s = "abcdabcab";
        day14 day = new day14();
        day.lengthOfLongestSubstring(s);
        System.out.println(s.charAt(3));

    }

}
